package com.gopay.webtest.controller.cloud;

import java.util.Date;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.gopay.webtest.controller.base.BaseController;
import com.gopay.webtest.handler.cloud.TransCloudSignHandler;
import com.gopay.webtest.util.DateUtils;
import com.gopay.webtest.vo.cloud.Cloud0609Vo;
import com.gopay.webtest.vo.cloud.Cloud0610Vo;
import com.gopay.webtest.vo.cloud.Cloud0611Vo;
import com.gopay.webtest.vo.cloud.Cloud0615Vo;
import com.gopay.webtest.vo.cloud.Cloud0616Vo;
import com.gopay.webtest.xml.XmlDao;

/**
 * 
 * ZhangZG
 * 2016年1月4日 
 * www.gopay.com.cn Inc.All rights reserved.
 */

@RequestMapping("/cloudQuery")
@Controller
public class CloudQueryController extends BaseController{
	
	
	@Resource(name = "xmlDao")
    private XmlDao xmlDao;
	
	@Resource(name="transCloudSignHandler")
	private TransCloudSignHandler transCloudSignHandler;
	
	
    @RequestMapping("/chargeBalanceQuery")
    public ModelAndView chargeBalanceQuery() {
        ModelAndView mv = new ModelAndView();     
        try {        	
        	 Map<String, String> map = xmlDao.readData4Map("cloud_apply", "balanceQuery");

             map.put("reqTime", DateUtils.format(new Date(), "yyyyMMddHHmmss"));
             mv = new ModelAndView("cloud.charge.queryBalance");
             mv.addObject("config", map);
             this.logger.info("^^^^^^^^^^^^^^^^^云平台查询页面初始化成功^^^^^^^^^^^^^^^^^");
        } catch (Exception e) {
            logger.error("跳转页面", e);
        }

        return mv;
    }
        
    @RequestMapping("/doBalanceQuery")
    public ModelAndView doBalanceQuery(@ModelAttribute Cloud0610Vo cloud0610Vo){
    	 ModelAndView mv = new ModelAndView();
         mv.setViewName("cloud.charge.doQueryBalance");

        try {
        	 this.logger.error("^^^^^^^^^^^^^^^^^云平台查询页面签名成功^^^^^^^^^^^^^^^^^");
             // 签名
        	 transCloudSignHandler.sign(cloud0610Vo.getTranCode()+"_"+cloud0610Vo.getVersion(), "signType", "signValue", cloud0610Vo, getRequest());

             mv.addObject("cloud0610Vo", cloud0610Vo);
         } catch (Exception e) {
             logger.error("执行申请", e);
         }
         return mv;
    }
    
    @RequestMapping("/chargeCertificateQuery")
    public ModelAndView chargeCertificateQuery() {
        ModelAndView mv = new ModelAndView();     
        try {        	
        	 Map<String, String> map = xmlDao.readData4Map("cloud_apply", "certificateQuery");

             map.put("reqTime", DateUtils.format(new Date(), "yyyyMMddHHmmss"));
             mv = new ModelAndView("cloud.charge.certificateQuery");
             mv.addObject("config", map);
             this.logger.info("^^^^^^^^^^^^^^^^^云平台查询页面初始化成功^^^^^^^^^^^^^^^^^");
        } catch (Exception e) {
            logger.error("跳转页面", e);
        }

        return mv;
    }
    
    @RequestMapping("/doCertificateQuery")
    public ModelAndView doCertificateQuery(@ModelAttribute Cloud0611Vo Cloud0611Vo){
    	 ModelAndView mv = new ModelAndView();
         mv.setViewName("cloud.charge.doCertificateQuery");
         try {
        	 this.logger.error("^^^^^^^^^^^^^^^^^云平台查询页面签名成功^^^^^^^^^^^^^^^^^");
             // 签名
        	 transCloudSignHandler.sign(Cloud0611Vo.getTranCode()+"_"+Cloud0611Vo.getVersion(), "signType", "signValue", Cloud0611Vo, getRequest());


             mv.addObject("Cloud0611Vo", Cloud0611Vo);
         } catch (Exception e) {
             logger.error("执行申请", e);
         }
         return mv;
    }
    
    @RequestMapping("/chargeTransQuery")
    public ModelAndView chargeTransQuery() {
        ModelAndView mv = new ModelAndView();     
        try {        	
        	 Map<String, String> map = xmlDao.readData4Map("cloud_apply", "transQuery");

             map.put("reqTime", DateUtils.format(new Date(), "yyyyMMddHHmmss"));
             map.put("endTime", DateUtils.format(new Date(), "yyyyMMddHHmmss"));
             mv = new ModelAndView("cloud.charge.transQuery");
             mv.addObject("config", map);
             this.logger.info("^^^^^^^^^^^^^^^^^云平台查询页面初始化成功^^^^^^^^^^^^^^^^^");
        } catch (Exception e) {
            logger.error("跳转页面", e);
        }

        return mv;
    }
    
    @RequestMapping("/doTransQuery")
    public ModelAndView doTransQuery(@ModelAttribute Cloud0609Vo cloud0609Vo){
    	 ModelAndView mv = new ModelAndView();
         mv.setViewName("cloud.charge.doTransQuery");
         try {
        	 this.logger.error("^^^^^^^^^^^^^^^^^云平台查询页面签名成功^^^^^^^^^^^^^^^^^");
             // 签名
        	 transCloudSignHandler.sign(cloud0609Vo.getTranCode()+"_"+cloud0609Vo.getVersion(), "signType", "signValue", cloud0609Vo, getRequest());


             mv.addObject("cloud0609Vo", cloud0609Vo);
         } catch (Exception e) {
             logger.error("执行申请", e);
         }
         return mv;
    }   
    @RequestMapping("/chargeApplyQuery")
    public ModelAndView chargeApplyQuery() {
    	ModelAndView mv = new ModelAndView();
    	try {
    		 Map<String, String> map = xmlDao.readData4Map("cloud_apply", "applyQuery");

             map.put("reqTime", DateUtils.format(new Date(), "yyyyMMddHHmmss"));
             mv = new ModelAndView("cloud.charge.queryApply");
             mv.addObject("config", map);
             this.logger.info("^^^^^^^^^^^^^^^^^云平台查询页面初始化成功^^^^^^^^^^^^^^^^^");
		} catch (Exception e) {
			logger.error("执行申请",e);
		}
    	return mv;
    }
    @RequestMapping("/doApplyQuery")
    public ModelAndView doApplyQuery(@ModelAttribute Cloud0615Vo cloud0615Vo) {
    	ModelAndView mv = new ModelAndView();
        mv.setViewName("cloud.charge.doApplyQuery");
    	try {
			this.logger.error("^^^^^^^^^^^^^^^^^云平台查询页面签名成功^^^^^^^^^^^^^^^^^");
			// 签名
			transCloudSignHandler.sign(cloud0615Vo.getTranCode() + "_" + cloud0615Vo.getVersion(), "signType", "signValue", cloud0615Vo, getRequest());

			mv.addObject("cloud0615Vo", cloud0615Vo);
		} catch (Exception e) {
			logger.error("执行申请",e);
		}
    	return mv;
    }
    @RequestMapping("/chargeBindCardQuery")
    public ModelAndView chargeBindCardQuery() {
    	ModelAndView mv = new ModelAndView();
    	try {
    		 Map<String, String> map = xmlDao.readData4Map("cloud_apply", "bindCardQuery");

             map.put("reqTime", DateUtils.format(new Date(), "yyyyMMddHHmmss"));
             mv = new ModelAndView("cloud.charge.queryBindCard");
             mv.addObject("config", map);
             this.logger.info("^^^^^^^^^^^^^^^^^云平台查询页面初始化成功^^^^^^^^^^^^^^^^^");
		} catch (Exception e) {
			logger.error("执行申请",e);
		}
    	return mv;
    }	
    @RequestMapping("/doBindCardQuery")
    public ModelAndView doBindCardQuery(@ModelAttribute Cloud0616Vo cloud0616Vo) {
    	ModelAndView mv = new ModelAndView();
        mv.setViewName("cloud.charge.doBindCardQuery");
    	try {
    		this.logger.error("^^^^^^^^^^^^^^^^^云平台查询页面签名成功^^^^^^^^^^^^^^^^^");
			// 签名
			transCloudSignHandler.sign(cloud0616Vo.getTranCode() + "_" + cloud0616Vo.getVersion(), "signType", "signValue", cloud0616Vo, getRequest());

			mv.addObject("cloud0616Vo", cloud0616Vo);
		} catch (Exception e) {
			logger.error("执行申请",e);
		}
    	return mv;
    }	
}
